/*静态登录*/
function login(serverpath,url1,url2,url3){
	 var userName = $("#userName").val();  
	 var passWord = $("#passWord").val(); 
	 var verifyCode= $("#verifyCode").val();
	 if(null == userName || "" == userName || undefined == userName){  
		common_a_div("请填写手机号码");
		//$("#userName").focus();
		return false;
	 }else if(userName.length<11){ 
		common_a_div("手机号码有误"); 
		//$("#userName").focus();
		return false;
	 }else{ 
		 //isShowImageVerifyCode(serverpath,userName);
		 $.ajax({
				url:serverpath+"/ajax/account/isMobile_Liantong.action",
				type:"post",
				data:"phone="+userName,
				async:false,
				dataType:"json",
				success:function (root){   
				if(root == "success"){//是联通号     
					 if(null == passWord || "" == passWord || undefined == passWord){ 
							common_a_div("请填写密码");
							//$("#passWord").focus();
					  		return false;
						 }else if($("#verifyCodeDiv").css("display") != "none" && (null == verifyCode || "" == verifyCode || undefined == verifyCode)){ 
							 common_a_div("请填写验证码");
							 //$("#verifyCode").focus();
						  	 return false;
						 }else{
						 	 common_a_div("正在登录，请稍后...");
							 jQuery.getJSON(serverpath+"/ajax/account/staticLogin.action?jsoncallback=?",
							    	    {userName:userName,passWord:passWord,verifyCode:verifyCode},function(data){
							    	        var status = data.resultCode;
							    	        var promptMessage = data.promptMessage;
							    	        var imageResult = data.imageResult;
							    	        if("true" == imageResult){
							    	        	changeImageCode_login(serverpath);
							    	        	$("#verifyCode").val("");
							    	        	$("#verifyCodeDiv").show();
							    	        }else{
							    	        	changeImageCode_login(serverpath);
							    	        	$("#verifyCode").val("");
							    	        	$("#verifyCodeDiv").hide();
							    	        }
										       if(status == "success"){
										    	    //校园活动 
										    	    //var sourceurl="http://119.163.193.23:17186/wo_activity/wocreative/index.jsp";
										    	    if("wocreative" == url3){
										    	    	jQuery.ajax({
										    				url:serverpath+"/ajax/account/mlink_ssoLogin.action",
										    				type:"post",
										    				data:{sourceurl:url1},
										    				async: false,
										    				dataType:"json",
										    				success:function (root){  
										    					location.href=root;//跳转至加密的校园活动页面
										    				}
										    		    }); 
										    	    } else if("lotteryActivity" == url3){
										    	    	location.href = serverpath+"/huodong/newsite_lottery.3.jsp";
										    	    } else{
											    	    if(url1 != null && url1 != "" && url1 != "null"){
											    	    	if(url3 != null && url3 != "" && url3 != "null"){
											    	    		if(url3 == "list"){
												    	    		if(url2 != null && url2 != "" && url2 != "null"){
												    	    			location.href=url1+"?"+url2;
												    	    		}else{
												    	    			location.href=url1;
												    	    		}
											    	    		}else{
											    	    			if(url1.indexOf("flag")!=-1){
											    	    				location.href=url1+"&resourceCode="+url2+"&columnId="+url3+"&version=3";
											    	    			}else{
											    	    				location.href=url1+"?resourceCode="+url2+"&columnId="+url3+"&version=3";
											    	    			}
											    	    		}
											    	    	}else{
											    	    		if(url2 != null && url2 != "" && url2 != "null"){
											    	    			location.href=url1+"?"+url2;
											    	    		}else{
											    	    			location.href=url1;
											    	    		}
											    	    	}
											    	    }else{
											    	    	location.href=serverpath+"/index.3.jsp";
											    	    }
										    	    }
										       }else{
										    	   var xyhd_ts="";
										    	   if("wocreative" == url3){
										    		   if("506500" == status){
										    			   xyhd_ts="此手机号尚未注册";
										    		   }else{
										    			   xyhd_ts="用户名或密码错误";
										    		   }
										    		   if(confirm(xyhd_ts+"，  是否返回校园活动首页？")){
										    			   location.href=url1;
											    	   }else{
											    		   //common_a_div(promptMessage);
												    	    //$("#userName").focus();
												    	    changeImageCode_login(serverpath);
											    	   } 
						         	               }else{ 
											    	    common_a_div(promptMessage);
											    	    //$("#userName").focus();
											    	    changeImageCode_login(serverpath);
						         	               }
										    	   
										       }
							  }); 
						 }
				}else{
					common_a_div("请输入山东省内联通手机号码");
					//$("#userName").focus();
				   	return false;
				}	
			}
		 }); 
		 
	 } 
}  
/*校验是否是山东联通号码*/
var mobFlag = true;
function isNotMobile(param,serverpath){
	   jQuery.ajax({
			url:serverpath+"/ajax/account/isMobile_Liantong.action",
			type:"post",
			data:{phone:param},
			async: false,
			dataType:"json",
			success:function (root){ 
				if(root == "success"){//是联通号
					mobFlag = false;
				} else {
					mobFlag = true;
				}
			}
	 });
	 return mobFlag; 
}

/*找回密码*/
function findPassWord(serverpath){
	 var phone = $("#phone").val();  
	 var messageVerifyCode= $("#messageVerifyCode").val();
	 if(null == phone || "" == phone || undefined == phone){  
		 common_a_div("请填写手机号码");
		 //$("#phone").focus();
		 return false;
	 }else if(phone.length<11){ 
		 common_a_div("手机号码有误"); 
		 //$("#phone").focus();
		 return false;
	 }else{
		 $.ajax({
				url:serverpath+"/ajax/account/isMobile_Liantong.action",
				type:"post",
				data:"phone="+phone,
				async:false,
				dataType:"json",
				success:function (root){   
				if(root == "success"){//是联通号    
					if(null == messageVerifyCode || "" == messageVerifyCode || undefined == messageVerifyCode){
						 common_a_div("请填写验证码"); 
						 //$("#messageVerifyCode").focus();
						 return false;
					 }else{
						 $.ajax({
						        type: "post",
						        dataType: "json",
						        url: serverpath+"/ajax/account/findPassWord.action",
						        data: "phone="+phone+"&messageVerifyCode="+messageVerifyCode,
						        success: function(root){ 
						            if(root == "success"){  
						            	common_atime_div("找回密码成功，新密码已下发您手机，请注意查收！",5000,serverpath+"/login/login.3.jsp");
						            	//location.href=serverpath+"/login/login.3.jsp";  
						            }else{
						            	  common_a_div(root);
						            	  //$("#phone").focus();
						            	/*common_a_div("找回密码失败，请重试！");*/
						            } 
						        }
						 }); 
					 } 
				}else{
					common_a_div("请输入山东省内联通手机号码");
					//$("#phone").focus();
				   	return false;
				}	
			}
		 }); 
		 
	 } 
}
/*注册*/
function register(serverpath,url1,url3){
	 var userName = $("#userName").val(); 
	 var messageVerifyCode= $("#messageVerifyCode").val();
	 var onepwd= $("#onepwd").val();
	 var twopwd= $("#twopwd").val();
	 if(null == userName || "" == userName || undefined == userName){ 
		 common_a_div("请填写手机号码"); 
		 //$("#userName").focus();
		 return false;
	 }else if(userName.length<11){ 
		 common_a_div("手机号码有误"); 
		 //$("#userName").focus();
		 return false;
	 }else{
		 $.ajax({
				url:serverpath+"/ajax/account/isMobile_Liantong.action",
				type:"post",
				data:"phone="+userName,
				async:false,
				dataType:"json",
				success:function (root){   
				if(root == "success"){//是联通号   
					 if(null == messageVerifyCode || "" == messageVerifyCode || undefined == messageVerifyCode){ 
						 common_a_div("请填写验证码");
						 //$("#messageVerifyCode").focus();
						 return false;
					 }else if(null == onepwd || "" == onepwd || undefined == onepwd){ 
						 common_a_div("请填写密码");
						 //$("#onepwd").focus();
						 return false;
					 }else if(onepwd.length<6 || onepwd.length>10){ 
						 common_a_div("密码请填写6-10个字符"); 
						//$("#onepwd").focus();
						 return false; 
					 }else if(null == twopwd || "" == twopwd || undefined == twopwd){ 
						 common_a_div("请填写确认密码");
						 //$("#twopwd").focus();
						 return false;
					 }else if(twopwd != onepwd){ 
						 common_a_div("密码不一致，请重新填写");
						//$("#twopwd").focus();
						 return false;
					 }else if($("#register_xy").attr("checked")!='checked'){
						 common_a_div("您还未接受沃玩家用户注册协议");
						 return false;
					 }else{  
						 $.ajax({
						        type: "post",
						        dataType: "json",
						        async: false,
						        url: serverpath+"/ajax/account/isRegistedForPhone.action",
						        data: "phoneNumber="+userName,
						        success: function(root){ 
					            if(root == "success"){   
					            	common_a_div("用户已存在，可直接登录");
					            }else{ 
					            	$.ajax({
					         	        type: "post",
					         	        dataType: "json",
					         	        async:false,
					         	        url: serverpath+"/ajax/account/userRegister.action",
					         	        data: "userName="+userName+"&messageVerifyCode="+messageVerifyCode+"&passWord="+onepwd,
					         	        success: function(root){  
					         	            if(root == "success"){
					         	               //校园活动 
									    	    //var sourceurl="http://119.163.193.23:17186/wo_activity/wocreative/index.jsp";
									    	    if("wocreative" == url3){
									    	    	jQuery.ajax({
									    				url:serverpath+"/ajax/account/mlink_ssoLogin.action",
									    				type:"post",
									    				data:{sourceurl:url1},
									    				async: false,
									    				dataType:"json",
									    				success:function (root){  
									    					location.href=root;//跳转至加密的校园活动页面
									    				}
									    		    });  
					         	            	}else{ 
						         	            	common_atime_div("注册成功",5000,serverpath+"/index.3.jsp"); 
						         	            	//common_atime_div("注册成功,请至登录页登录使用",5000,serverpath+"/login/login.3.jsp"); 
						         	            	//location.href=serverpath+"/login/login.3.jsp"; 
					         	            	}
					         	            }else{
					         	            	 if("wocreative" == url3){
					         	            		 	if(confirm("注册失败，  是否返回校园活动首页？")){
										    			   location.href=url1;
											    	   }else{ 
												    	   changeImageCode_login(serverpath);
											    	   }  
					         	            	 }else{
					         	            		 common_a_div(root);
							         	            	//$("#userName").focus();
							         	            	//common_a_div("注册失败，请重试！");
					         	            	 } 
					         	            } 
					         	        }
					            	 });  
					            }
					        }
						  });   
					 } 
				}else{
					common_a_div("请输入山东省内联通手机号码");
					//$("#userName").focus();
				   	return false;
				}	
			}
		 }); 
	 } 
}
/*校验注册的手机号是否存在*/
function isRegistedForPhone(serverpath){
	 var phoneNumber = $("#userName").val();
	 $.ajax({
	        type: "post",
	        dataType: "json",
	        url: serverpath+"/ajax/account/isRegistedForPhone.action",
	        data: "phoneNumber="+phoneNumber,
	        success: function(root){
	            if(root == "success"){   
	            	 
	            } 
	        }
	 }); 
}

/*更换验证码*/
function changeImageCode(serverpath){
    var srcStr = serverpath+"/common/virifyCode.action?value="+new Date().getTime();
 	jQuery("#imageCode").attr("src",srcStr); 
 }
function changeImageCode_login(serverpath){
    var srcStr = serverpath+"/common/virifyCode.action?value="+new Date().getTime();
 	jQuery("#imageCode_yzm").attr("src",srcStr); 
 }


/*免费获取验证码*/
function getFreeCode(phone_div_name,reg_or_find,serverpath){
	var p_d_n= $("#"+phone_div_name).val();
	if(null == p_d_n || "" == p_d_n || undefined == p_d_n){  
		 common_a_div("请填写手机号码");
		 //$("#"+phone_div_name).focus();
		 return false;
	 }else if(p_d_n.length<11){  
		 common_a_div("手机号码有误");
		 //$("#"+phone_div_name).focus();
		 return false;
	 }else{
		 if($("#freeCode").html() != "免费获取验证码")return;
		 $.ajax({
				url:serverpath+"/ajax/account/isMobile_Liantong.action",
				type:"post",
				data:"phone="+p_d_n,
				async:false,
				dataType:"json",
				success:function (root){   
				if(root == "success"){//是联通号   则下发验证码
					$.ajax({
						url:serverpath+"/ajax/account/"+reg_or_find+".action",
						type:"post",
						data:"userMobile="+p_d_n,
						async:false,
						dataType:"json",
						success:function (root){
						if(root == "success"){ 
						    //common_a_div("验证已下发您手机，请注意查收并完成！");
							mycount2();
						}else{
							common_a_div(root);
							//$("#"+phone_div_name).focus();
						}
					}
				 }); 
				}else{
					common_a_div("请输入山东省内联通手机号码");
					//$("#"+phone_div_name).focus();
				   	return false;
				}	
			}
		 }); 
   }
} 
function mycount3(wp_count){
	if (parseInt(wp_count) == 1) {
		$("#freeCode").html("免费获取验证码");
	} else {
		wp_count = parseInt(wp_count) - 1;
		$("#freeCode").html("<span style='color:red'> "+wp_count+" </span>秒后可重新获取");
		setTimeout("mycount3("+wp_count+")",1000);
	}
}
/*修改密码*/
function changepwd(serverpath){
	var oldpwd = $("#oldpwd").val();
	var newpwd = $("#newpwd").val();
	var newpwd2 = $("#newpwd2").val();
	if(oldpwd==""){ 
		$(".pop_cover").show();
		$(".c_pop").show();
		$("#quxiaoresult").html("输入旧密码");
		setTimeout(function(){
			$(".pop_cover").hide();
			$(".c_pop").hide();
		},3000);
		//$("#showmsg").show().html("输入旧密码");
		//$("#oldpwd").focus();
		return;
	}
	if(newpwd==""){
		$(".pop_cover").show();
		$(".c_pop").show();
		$("#quxiaoresult").html("输入新密码");
		setTimeout(function(){
			$(".pop_cover").hide();
			$(".c_pop").hide();
		},3000);
		//$("#showmsg").show().html("输入新密码"); 
		//$("#newpwd").focus();
		return;
	}
	if(newpwd.length<6 || newpwd.length>10){
		$(".pop_cover").show();
		$(".c_pop").show();
		$("#quxiaoresult").html("密码请填写6-10个字符");
		setTimeout(function(){
			$(".pop_cover").hide();
			$(".c_pop").hide();
		},3000);
		//$("#showmsg").show().html("密码请填写6-10个字符"); 
		//$("#newpwd").focus();
		return;
	}
	if(newpwd2==""){
		$(".pop_cover").show();
		$(".c_pop").show();
		$("#quxiaoresult").html("确认密码");
		setTimeout(function(){
			$(".pop_cover").hide();
			$(".c_pop").hide();
		},3000);
		//$("#showmsg").show().html("确认密码"); 
		//$("#newpwd2").focus();
		return;
	}
	if(oldpwd==newpwd){
		$(".pop_cover").show();
		$(".c_pop").show();
		$("#quxiaoresult").html("新密码不能和旧密码一致");
		setTimeout(function(){
			$(".pop_cover").hide();
			$(".c_pop").hide();
		},3000);
		//$("#showmsg").show().html("新密码不能和旧密码一致"); 
		//$("#newpwd").focus();
		return;
	}
	if(newpwd2!=newpwd){ 
		$(".pop_cover").show();
		$(".c_pop").show();
		$("#quxiaoresult").html("密码不一致");
		setTimeout(function(){
			$(".pop_cover").hide();
			$(".c_pop").hide();
		},3000);
		//$("#showmsg").show().html("密码不一致");
		//$("#newpwd2").focus();
		return;
	}
	 $.ajax({
	        type: "post",
	        dataType: "json",
	        url: serverpath+"/ajax/account/changeUserPwd.action",
	        data: "oldpwd="+oldpwd+"&newpwd="+newpwd+"&newpwd2="+newpwd2,
	        success: function(root){
	            if(root == "success"){   
	            	$(".pop_cover").show();
	        		$(".c_pop").show();
	        		$("#quxiaoresult").html("修改成功");
	            	//$("#showmsg").show().html("修改成功"); 
	            	$("#oldpwd").val("");
	            	$("#newpwd").val("");
	            	$("#newpwd2").val("");
	            	setTimeout(function(){
	        			$(".pop_cover").hide();
	        			$(".c_pop").hide();
	        		},3000);
	            } else if(root == "return_grxx"){/*非正常渠道修改密码  get */
	            	/*跳转至个人中心首页*/
	            	location.href=serverpath+"/usercenter/personal.3.jsp?page_at=ihome"; 
	            } else{
	            	//$("#showmsg").html("修改失败"); 
	            	$(".pop_cover").show();
	        		$(".c_pop").show();
	        		$("#quxiaoresult").html(root);
	        		setTimeout(function(){
	        			$(".pop_cover").hide();
	        			$(".c_pop").hide();
	        		},3000);
	            	//$("#showmsg").show().html(root);
	            	$("#oldpwd").focus();
	            }
	        }
	 }); 
}
/*  guop         start   */






/*  guop         end   */